<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>财务管理-老人出院结算</title>
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link href="/caiwu_assets/css/bootstrap.min.css" rel="stylesheet">
	<link href="/caiwu_assets/css/style.css" rel="stylesheet">
	<link href="/caiwu_assets/css/font-awesome.css" rel="stylesheet">
</head>

<body>
	<div class="container-fluid">
		<div class="om-ctl-mes">
			<div class="title">
				<div class="col-xs-12"><span class="fa fa-list-ul"> 财务管理</span><b class="fa fa-caret-right"></b><i>员工工资记录</i></div>
			</div>
			<div class="seltemple">
				<div class="col-xs-12">
					<form class="form-inline" method="get" action="/admin_wages">
                    <div class="col-xs-3 mes-group"><label>部门</label><select name="department"><option value="0">请选择</option><?foreach($tDIDatas as $tDIRow){?><option value="<?=$tDIRow['num']?>" <?if($tDIRow['num'] == $pDepartment)echo 'selected';?>><?=$tDIRow['introduce']?></option><?}?></select></div>
				</form>
				</div>
			</div>
			<div  class="mes-conttent col-xs-12">
				<table class="table off-table">
	              <thead>
	             	<tr>
			        <th>编号</th>
			        <th>部门名称</th>
			        <th>员工姓名</th>
			        <th>基本工资</th>
			        <th>本月出勤</th>
			        <th>应发工资</th>
			        <th>实发工资</th>
			        <th>是否发放工资</th>
			        <th>工资记录</th>
		            </tr>
	              </thead>
	             <tbody>
                    <?foreach($tDatas as $tRow){?>
                    <tr>
                        <td name="w_id"><?=$tRow['id']?></td>
                        <td><?=$tRow['department']?></td>
                        <td><?=$tRow['name']?></td>
                        <td name="basic_fee"><?=$tRow['basic_fee']?></td>
                        <td name="attendence_days"><?=$tRow['attendence_days']?></td>
                        <td name="prefee"><?=$tRow['prefee']?></td>
                        <td><?if(empty($tRow['is_issue'])){?><input type="text" name="payment" value="" placeholder="请输入工资数"/><?}else{?><?=$tRow['payment']?><?}?></td>
                        <td><?if(empty($tRow['is_issue'])){?><button type="button" class="issueBtn">确认发放</button><?}else{?>已发放<?}?></td>
                        <td>
                            <button type="button" onclick="location.href='/admin_wages/detail?id=<?=$tRow['id']?>'" class="tooltips">查看</button>
                        </td>
                    </tr>
                    <?}?>
	            </tbody>
              </table>
            <?=$tShow?>
			</div>
		</div>
    </div>
        <script type="text/javascript" src="/caiwu_assets/js/jquery.min.js"></script>
<script>
$('form').change(function(){
    $('form').submit();
});
/*获取地址栏参数*/
function GetQuery(key){
	var search = location.search.slice(1);//得到get方式提交的查询字符串
	var arr = search.split("&");
	for(var i = 0; i < arr.length; i++){
		var ar = arr[i].split("=");
		if(ar[0] == key){
			return ar[1];
		}
	}
}
    var color="#eeeeee";
    $("#table_list tr:odd td").css("background-color",color);  //改变偶数行背景色
    /* 把背景色保存到属性中 */
    $("#table_list tr:odd").attr("bg",color);
$(function(){
	var offalert="<div class='off-alert'></div>",
	    html = "<div class='mark'></div>"
	           +"<div class='off-alert instrnew-alert'>"
				  +"<h3>确认发放<span id='close'>×</span></h3>"
				  +"<p><span class='name'></span>实发工资为<small class='fee'></small>，是否确认发放?</p>"
          +"<div class='btns'><button class='issue-btn'>确认</button><button>取消</button></div>"
          +"</div>";
	   $("body").prepend($(html))
    $(".mark").css("height",$(document).height()+"px")		
   $(".mark").addClass('hidden')	
   $(".off-alert").addClass('hidden')
    $('.issueBtn').each(function(){
        $(this).on('click',function(){
            var prefee = $(this).parent().parent().find('td[name="prefee"]').text();
            var w_id = $(this).parent().parent().find('td[name="w_id"]').text();
            var basic_fee = $(this).parent().parent().find('td[name="basic_fee"]').text();
            var attendence_days = $(this).parent().parent().find('td[name="attendence_days"]').text();
            var payment = $(this).parent().parent().find('input[name="payment"]').val();
            if(payment == ''){
                alert('金额不能为空');return;
            }
           $('.mark').show()
           $('.off-alert').show()
           $(".off-alert").removeClass('hidden')
           $(".mark").removeClass('hidden')
           $('.off-alert p span').html($(this).parent().parent().find('td').eq(2).html())
           $('.off-alert p small').html($(this).parent().parent().find('td').eq(6).val())
           $('.issue-btn').click(function(){
            $.post('/admin_wages',{ prefee:prefee,w_id:w_id,basic_fee:basic_fee,attendence_days:attendence_days,payment:payment },function(obj){
                if(obj.status == 0){
                    alert(obj.msg);return;
                }else{
                    alert(obj.msg);location.href="/admin_wages";
                }
            });
           
           });
        });    
    });
      $("#off-btn").click(function(){
       
     })
    $("#close").click(function(){
           $('.mark').hide()
           $('.off-alert').hide()
           $(".off-alert").addClass('hidden')
           $(".mark").addClass('hidden')
     })
})

</script>
</body>
</html>
